package webgamemaker.Common;

import java.util.ArrayList;

import com.google.gwt.widgetideas.graphics.client.GWTCanvas;


public class MapData 
{
	public String name;
	public ArrayList<TileSet> listTileSet;
	public TileData tiles[][];
	public int width, height, num_layer;
	public int tileWidth, tileHeight;
	
	public MapData()
	{
		listTileSet = new ArrayList<TileSet>();
		tileWidth = 32;
		tileHeight = 32;
	}
	
	public MapData(int width, int height, int num_layer)
	{
		this();
		resize(width, height, num_layer);
	}
	
	public void resize(int width, int height, int num_layer)
	{
		TileData tiles[][] = new TileData[width*height][num_layer];
		for(int k = 0; k < num_layer; k++)
		{
			if(k < this.num_layer)
			{
				for(int i=0; i < this.width && i < width; i++)
					for(int j = 0; j < this.height && j < height; j++)
						tiles[i+j*width][k] = this.tiles[i+j*this.width][k];
			}
		}
		this.width = width;
		this.height = height;
		this.num_layer = num_layer;
		this.tiles = tiles;
	}
	
	public void addTileSet(TileSet tileset)
	{
		listTileSet.add(tileset);
	}
	
	public void removeTileSet(TileSet tileset)
	{
		listTileSet.remove(tileset);
	}

}
